class System::UsersController < ApplicationController
  before_filter :authorize
  
  def show
    @user = User.find(session[:user_id])
    if(@user.in_vacations)
      @vacations = 'Sim'
    else
      @vacations = 'Nao'
    end
  end
  
  def edit
    @user = User.find(session[:user_id])
    @departments = Department.find(:all, :order => :name).map {|c| [c.name, c.id]}
  end
  
  def update
    @user = User.find(session[:user_id])
    if @user.update_attributes(params[:user])
      flash[:notice] = 'Usu&aacute;rio atualizado com sucesso!<br/><br/>'
      redirect_to :action => :show
    else
      flash[:notice] = 'Usu&aacute;rio n&atilde;o atualizado. Favor corrigir os erros.<br/><br/>'
      redirect_to :action => :edit
    end
  end
  
end
